package com.fuluwa.interfaces.category.web.filter;

import java.util.Collection;

import com.alibaba.fastjson.serializer.PropertyFilter;
import com.alibaba.fastjson.serializer.ValueFilter;

public class CategoryFilter {

	public static class CategoryPropFileter implements PropertyFilter {
		@Override
		public boolean apply(Object source, String name, Object value) {
			if (name.equals("pcid") || name.equals("cid") || name.equals("name") || name.equals("list")) {
				return true;
			}
			return false;
		}
	}

	public static class CategoryValueFilter implements ValueFilter {
		@Override
		public Object process(Object source, String name, Object value) {
			if (name.equals("list") && value instanceof Collection) {
				if (((Collection<?>) value).size() == 0) {
					return null;
				}
			}
			return value;
		}
	}
}
